unit CriticalSectionEx;

interface

uses
  Winapi.Windows;

type
  TCriticalSectionEx = class
  protected
    m_CriticalSection: TRTLCriticalSection;
  public
    constructor Create;
    destructor Destroy; override;
    procedure Lock;
    procedure UnLock;
  end;

implementation

constructor TCriticalSectionEx.Create;
begin
  inherited Create;
  InitializeCriticalSection(m_CriticalSection);
end;

destructor TCriticalSectionEx.Destroy;
begin
  DeleteCriticalSection(m_CriticalSection);
  inherited Destroy;
end;

procedure TCriticalSectionEx.Lock;
begin
  EnterCriticalSection(m_CriticalSection);
end;

procedure TCriticalSectionEx.UnLock;
begin
  LeaveCriticalSection(m_CriticalSection);
end;


end.
